home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / osr5 / sco / scripts / cmp_termio < prev    next >
Encoding:
AWK Script  |  1997-08-26  |  2.4 KB  |  90 lines

  1. #!/usr/local/bin/gawk -f
  2. #!/usr/bin/awk -f
  3. # @(#) cmp_termio.gawk 2.0 92/06/29
  4. # 91/10/15 john h. dubois iii (john@armory.com)
  5. # 92/02/16 added help option
  6. # 92/03/14 changed incorrect continue to next
  7. # 92/05/01 changed to #!awk script
  8. # 92/06/29 Fixed assorted problems; improved format
  9.  
  10. # todo: compare more than two sets of termio output.
  11.  
  12. BEGIN {
  13.     Name = "cmp_termio"
  14.     if (ARGC != 3) {
  15.     print \
  16. Name ": Compare two lists of stty output.\n" \
  17. "Usage: " Name " file1 file2\n" \
  18. "file1 and file2 are stty output.\n" \
  19. "Lines must be either fields delimited by semicolons, with each field\n" \
  20. "consisting of a name followed by whitespace and then a value (with '='\n" \
  21. "considered whitespace), or a list of whitespace-separated names with the\n" \
  22. "value indicated by the presence or lack of the name or the presence or\n" \
  23. "lack of a '-' somewhere in the name.  Two names separated by an '=' on\n" \
  24. "this type of line will also be recognized as name-value pairs.\n"
  25.     print \
  26. "Example data:\n" \
  27. "speed 38400 baud;   ispeed 38400 baud;   ospeed 38400 baud;\n" \
  28. "line = 0; intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = ^@;\n" \
  29. "swtch <undef>;susp <undef>;start = ^Q;stop = ^S;\n"\
  30. "-parenb -parodd cs8 -cstopb -hupcl cread -clocal -loblk -ctsflow -rtsflow\n" \
  31. "-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc\n" \
  32. "ixon ixany -ixoff\n" \
  33. "isig icanon -xcase echo echoe echok -echonl -noflsh iexten -tostop\n" \
  34. "opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel"
  35.  
  36.     ExitNow = 1
  37.     exit(0)
  38.     }
  39.  
  40.     file = 0
  41. }
  42.  
  43. FNR == 1 {
  44.     file++
  45. }
  46.  
  47. function value_param(param,  comp) {
  48.     split(param,comp," +")    # get parameter name into comp[1]
  49.     # Get rid of parameter name and any spaces and = that follow
  50.     sub("^ *[^ ]+[ =]+","",param)
  51.     list[file,comp[1]] = param
  52.     params[comp[1]]
  53. }
  54.  
  55. /;/ {
  56.     split($0,args,"; *")
  57.     for (a in args)
  58.     value_param(args[a])
  59.     next
  60. }
  61.  
  62. {
  63.     for (i = 1; i <= NF; i++) {
  64.     param = $i
  65.     # min and time are on a line with switches
  66.     if ($(i+1) == "=") {
  67.         value_param(param " = " $(i+2))
  68.         i += 2
  69.     }
  70.     else {
  71.         sub("-","",param)
  72.         list[file,param] = $i
  73.         params[param]
  74.     }
  75.     }
  76. }
  77.  
  78. END {
  79.     if (ExitNow)
  80.     exit(0)
  81.     format = "%-15s %-15s %s"
  82.     line = sprintf(format,"Parameter",ARGV[1],ARGV[2])
  83.     print line
  84.     gsub(".","-",line)
  85.     print line
  86.     for (param in params)
  87.     if (list[1,param] != list[2,param])
  88.         printf format "\n",param,list[1,param],list[2,param]
  89. }
  90.